package com.example.demo.tests;

import com.example.demo.common.Utils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;

public class ArticleReplyPage extends Utils {
    public static String url = "http://82.157.143.27:8081/index.html";

    public ArticleReplyPage() {
        super(url);
    }

    //评论他人帖子
    public void CreateReply() throws InterruptedException {
        driver.findElement(By.cssSelector("#artical-items-body > div:nth-child(3) > div > div.col > div.text-truncate > a > strong")).click();
        Thread.sleep(2000);

        WebElement element = driver.findElement(By.cssSelector("#article_details_reply > div.CodeMirror.cm-s-default.CodeMirror-wrap.CodeMirror-empty > div.CodeMirror-scroll > div.CodeMirror-sizer > div > div > div > div.CodeMirror-code > div > pre"));
        Actions actions = new Actions(driver);
        actions.doubleClick(element).perform();
        actions.moveToElement(element).sendKeys("测试1").perform();

        Thread.sleep(2000);
        driver.findElement(By.cssSelector("#details_btn_article_reply > span")).click();
    }


    //查看回复
    public void CheckReply() throws InterruptedException {

        driver.findElement(By.cssSelector("#artical-items-body > div:nth-child(3) > div > div.col > div.text-truncate > a > strong")).click();
        Thread.sleep(2000);

        driver.findElement(By.cssSelector("#details_article_reply_content_28 > p:nth-child(1)"));
    }


}
